<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="ibox-content">
        	<form class="form-horizontal m" id="form-leave-add">
				<input name="deptId"  type="hidden" id="treeId"/>
				<input name="userId"  type="hidden" id="chooseId"/>
				<!--<div class="form-group">-->
					<!--<label class="col-sm-3 control-label">请假标题：</label>-->
					<!--<div class="col-sm-8">-->
						<!--<input id="leaveTitle" name="leaveTitle" class="form-control" type="text">-->
					<!--</div>-->
				<!--</div>-->
				<div class="form-group">
					<label class="col-sm-3 control-label">请假类型：</label>
					<div class="col-sm-4">
						<select id="leaveType" name="leaveType"  class="form-control m-b" th:with="type=${@dict.getType('sys_leave_type')}">
							<option th:each="dict : ${type}" th:text="${dict['dictLabel']}" th:value="${dict['dictValue']}"
							th:selected="${dict['isDefault'] == 'Y' ? true : false}" th:disabled="${dict['status'] =='1' ? true :false}"></option>
						</select>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-3 control-label">请假人：</label>
					<div class="col-sm-8">
						<input id="leavePeople" name="leavePeople" class="form-control" type="text">
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-3 control-label">请假开始时间：</label>
					<div class="col-sm-4">
						<input id="commonDateTimeStart" name="beginDate" class="form-control" type="text" readonly>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-3 control-label">请假结束时间：</label>
					<div class="col-sm-4">
						<input id="commonDateTimeEnd" name="endDate" class="form-control" type="text" readonly>
					</div>
				</div>
				<!--<div class="form-group">-->
					<!--<label class="col-sm-3 control-label">所属部门：</label>-->
					<!--<div class="col-sm-8">-->
						<!--<input id="deptId" name="deptId" class="form-control" type="text">-->
					<!--</div>-->
				<!--</div>-->
				<div class="form-group">
					<label class="col-sm-3 control-label">所属部门：</label>
					<div class="col-sm-4">
						<input class="form-control" type="text" name="deptName" onclick="selectDeptTree()" readonly="true" id="treeName">
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-3 control-label">请假原因：</label>
					<div class="col-sm-8">
						<textarea id="leaveReason" name="leaveReason" class="form-control" style="height: 100px;"></textarea>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-3 control-label">审批人：</label>
					<div class="col-sm-3">
						<input class="form-control" type="text" name="userName" onclick="chooseUser()" readonly="true" id="chooseName">
					</div>
				</div>
				<!--<div class="form-group">-->
					<!--<label class="col-sm-3 control-label">备注：</label>-->
					<!--<div class="col-sm-8">-->
						<!--<textarea id="remark" name="remark" class="form-control" style="height: 100px;"></textarea>-->
					<!--</div>-->
				<!--</div>-->
				<div class="form-group">
					<div class="form-control-static col-sm-offset-9">
						<button type="submit" class="btn btn-primary">提交</button>
						<button onclick="$.modal.close()" class="btn btn-danger" type="button">关闭</button>
					</div>
				</div>
			</form>
		</div>
	</div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		var prefix = ctx + "module/leave"
		$("#form-leave-add").validate({
			rules:{
                leaveTitle:{
					required:true,
                    maxlength: 100
				},
                leavePeople :{
                    required:true,
                    maxlength: 20
				},
                beginDate :{
                    required:true,
				},
                endDate :{
                    required:true,
                },
				deptName:{
                    required:true,
                },
				leaveReason:{
                    required:true,
                    maxlength: 500
				}
			},
			submitHandler: function(form) {
				$.operate.save(prefix + "/add", $('#form-leave-add').serialize());
			}
		});
        /*用户管理-新增-选择部门树*/
        function selectDeptTree() {
            var treeId = $("#treeId").val();
            var deptId = $.common.isEmpty(treeId) ? "100" : $("#treeId").val();
            var url = ctx + "system/dept/selectDeptTree/" + deptId;
            var options = {
                title: '选择部门',
                width: "380",
                height: "380",
                url: ctx + "system/dept/selectDeptTree/" + deptId,
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }

        function doSubmit(index, layero){
            var tree = layero.find("iframe")[0].contentWindow.$._tree;
            if ($.tree.notAllowParents(tree)) {
                var body = layer.getChildFrame('body', index);
                $("#treeId").val(body.find('#treeId').val());
                $("#treeName").val(body.find('#treeName').val());
                layer.close(index);
            }
        }

        function chooseUser() {
            var url = ctx + "system/user/chooseUser/";
            $.modal.open("选择审批人", url, '600', '380');
        }
	</script>
</body>
</html>
